package com.liuceng.zen.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.app.VelocityEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.velocity.VelocityEngineUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
@RequestMapping("/test")
public class TestController {

  @Autowired
  VelocityEngine velocityEngine;

  @RequestMapping(value = "/vm", method = RequestMethod.GET)
  public void mv(HttpServletRequest req, HttpServletResponse res) throws Exception {
    Map<String, Object> model = new HashMap<>();
    model.put("domain", "http://www.baidu.com");
    model.put("tname", "xx商城");
    String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "test.vm", model);
    System.out.println(text);
  }
}
